<!DOCTYPE html >
<html response.AddHeader( "Access-Control-Allow-Origin", "*"); response.AddHeader( "Access-Control-Allow-Methods", "PUT,GET,POST,OPTIONS"); response.AddHeader( "Access-Control-Allow-Headers", "X-Requested-With, Content-Type, X-File-Name");>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" href="css/home.css">
		<link rel="stylesheet" href="css/base.css">
		<!--<link href="css/index.css" type="text/css" rel="stylesheet" />-->
		<script type="text/javascript" src="http://api.map.baidu.com/api?key=&v=1.1&services=true"></script>
		<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
		<script type="text/javascript" src="js/index.js"></script>
		<script type="text/javascript" src="js/setting.js"></script>
		<!--<script type="text/javascript" src="js/compangImg.js"></script>-->
		<script type="text/javascript" src="js/personInfro.js"></script>
		<title>舆情定制</title>
	</head>

	<body>
		<div class="wholePublic-box">
			<div class="wholePublic-header clearfix">
				<div class="wholePublic-logo fl ">
					<a href="index-logged.html"><img src="images/logo-2.png" /></a>
				</div>
				<div class="wholePublic-header-list fl">
					<ul class="clearfix">
						<li onclick="javascript:window.location='wholePublic-company.html'">全部舆情</li>
						<li onclick="javascript:window.location='my-custom.html'">舆情定制</li>
						<li onclick="javascript:window.location='analysis.html'">分析报告</li>
						<li onclick="javascript:window.location='thinkTank.html'">智库</li>
						<li onclick="javascript:window.location='contactUs.html'">联系我们</li>
					</ul>
				</div>
				<div class="wholePublic-header-right fr">
					<ul class="clearfix">
						<li id='line'><img src="images/line-2.png" /></li>
						<li onclick="javascript:window.location='my-custom.html'">我的定制</li>
						<li id="exit"><img src="images/exit-2.png" /></li>
						<li class="setting-icon">
							<div id="setting-icon"><img src="images/setting-icon.png" /></div>
							<div class="setting-list">
								<span class="setting-arrow"></span>
								<ul>
									<li onclick="javascript:window.location='company-setting.html'">企业认证</li>
									<li onclick="javascript:window.location='financial-setting.html'">财务中心</li>
								</ul>
							</div>
						</li>
					</ul>

				</div>

			</div>
			<div class="grcolor-box"></div>

			<div class="container">
				<div class="setting-line">
					<ul class="clearfix">
						<li class="setting-line-selected">企业认证</li>
						<li>申请管理员认证</li>
					</ul>
				</div>
				<!--企业认证-->
				<div class="setting-item clearfix" id="ident">
					<div class="company-setting-title">企业信息</div>
					<div class="fl ident-img">
						<div class="imgBox">
							<div class="addIcon">+</div>
							<div>公司Logo</div>
						</div>
						<img src="" alt="未显示" id="img" width="200px" height="200px" />
						<div id="container">
							<input type="file" id="headfiles" value="">
						</div>
					</div>
					<div class="up-infro fl">
						<div><span>企业全称</span><input placeholder="输入企业全称" class="input-4" id="name" /></div>
						<div><span>成立时间</span><input placeholder="输入成立时间" class="input-4" id="establish_time" /></div>
						<div><span>办公地址</span><input placeholder="输入办公地址" class="input-4" id="address" /></div>
						<div><span>注册资本</span><input placeholder="输入注册资本" class="input-4" id="register_capital" /></div>
						<div><span>企业介绍</span><input placeholder="输入企业介绍" class="input-4" id="introduce" /></div>
						<div><span>企业代表</span><input placeholder="输入企业代表" class="input-4" id="legal_represent" /></div>
						<div><span>经营状态</span><input placeholder="输入经营状态" class="input-4" id="business_state" /></div>
						<div><span>公司类型 </span><input placeholder="输入公司类型" class="input-4" id="type" /></div>
						<div><span>经营范围 </span><input placeholder="输入经营范围 " class="input-4" id="business_range" /></div>
						<div><span>注册号</span><input placeholder="输入登记号" class="input-4" id="register_num" /></div>
						<div><span>组织机构代码</span><input placeholder="输入组织机构代码" class="input-4" id="organization_code" /></div>
						<div><span>统一社会信用代码</span><input placeholder="输入统一社会信用代码" class="input-4" id="social_credit_code" /></div>
						<div class="whole-btn company-btn" onclick="addCompany()"><button>确定</button></div>
					</div>
				</div>
			</div>

		</div>
	</body>

</html>
<script src="js/imgUp/jquery.min.js"></script>
<script src="js/imgUp/plupload.full.min.js"></script>
<script src="js/imgUp/qiniu.js"></script>
<script src="js/imgUp/myUploader.js"></script>
<script>
	var companyId;
	//企业认证
	$("#ident input").focus(function() {
		$(this).css("border", "1px solid white");
	});

	function addCompany() {
		var social_credit_code = /^((1{1}[1-39]{1})|(5{1}[1-39]{1})|(9{1}[1-3]{1})|(Y1))[0-9]{6}[0-9A-HJ-NP-RT-UW-Y]{10}$/;
		if($("#name").val() == "") {
			$("#name").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#establish_time").val() == "") {
			$("#establish_time").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#address").val() == "") {
			$("#address").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#register_capital").val() == "") {
			$("#register_capital").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#introduce").val() == "") {
			$("#introduce").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#legal_represent").val() == "") {
			$("#legal_represent").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#business_state").val() == "") {
			$("#business_state").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#type").val() == "") {
			$("#type").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#business_range").val() == "") {
			$("#business_range").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#register_num").val() == "") {
			$("#register_num").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#organization_code").val() == "") {
			$("#organization_code").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#social_credit_code").val() == "") {
			$("#social_credit_code").css("border", "1px solid #d63d3f");
			return false;
		}else if(!social_credit_code.test($("#social_credit_code").val())) {
			alert("请输入正确格式的统一社会信用代码");
			return false;
		}else if($(".companyLogo").attr("src") == "") {
			alert("请上传公司Logo")
			return false;
		} else {
			var datas = {
				'name': $("#name").val(),
				'establish_time': $("#establish_time").val(),
				'address': $("#address").val(),
				'introduce': $("#introduce").val(),
				'logo': $("#img").attr("src"),
				'legal_represent': $("#legal_represent").val(),
				'register_capital': $("#register_capital").val(),
				'register_num': $("#register_num").val(),
				'organization_code': $("#organization_code").val(),
				'social_credit_code': $("#social_credit_code").val(),
				'type': $("#type").val(),
				'business_state': $("#business_state").val(),
				'business_range': $("#business_range").val(),
			};
			var data = JSON.stringify(datas);
			$.ajax({
				type: "post",
				url: 'http://139.224.208.224:8080/qi-radar/company/addCompany',
				dataType: 'json',
				contentType: "application/json ",
				asycn: false,
				data: data,
				success: function(data) {
					if(data.code == 0) {
						console.log(data)
						companyId=data.data;
						alert("添加成功")
						$("#name").val("");
						$("#establish_time").val("");
						$("#address").val("");
						$("#introduce").val("");
						$("#legal_represent").val("");
						$("#register_capital").val("");
						$("#register_num").val("");
						$("#organization_code").val("");
						$("#social_credit_code").val("");
						$("#type").val("");
						$("#business_state").val("");
						$("#business_range").val("");
					} else {
						alert(data.errMsg)
					};
				}
			});
		}
	};
	//页面跳转
	$(".setting-line ul li").eq(1).click(function(){
		window.location.href="admin-setting.html?id="+companyId;
	})
</script>